import { defineStore } from 'pinia'
import { ref } from 'vue'
import type { SelectOptionData } from '@arco-design/web-vue'
import { getSystemDictData, type SystemDictDataItem } from '@/apis/system'

const storeSetup = () => {
  const dictData = ref<Record<string, SelectOptionData[]>>({})

  const getDictData = async (code: string) => {

    console.log(dictData.value, 'dictDatadictDatadictData');


    const res = await getSystemDictData({ dictCode: code })
    dictData.value[code] = res.data.map(dict => {
      return {
        label: dict.name,
        value: dict.value
      }
    })
  }

  return {
    dictData,
    getDictData
  }
}

export const useDictStore = defineStore('dict', storeSetup, { persist: false })
